*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: #ffffff;
  color: #000000;
  font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffff;
  border-bottom: 1px solid #e9e9ea;
  display: flex;
  align-items: center;
  padding: 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

nav::-webkit-scrollbar {
  display: none;
}

nav.hidden {
  display: none;
}

.nav-brand {
  font-weight: 800;
  font-size: 14px;
  color: #000000;
  padding: 14px 16px 14px 0;
  border-right: 1px solid #e9e9ea;
  margin-right: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

nav a {
  display: block;
  padding: 14px 12px;
  font-size: 13px;
  color: #666666;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s;
}

nav a:hover {
  color: #000000;
}

nav a.active {
  color: #000000;
  border-bottom-color: #000000;
  font-weight: 700;
}

.nav-right {
  margin-left: auto;
  padding-left: 16px;
  flex-shrink: 0;
}

.wrap {
  min-height: calc(100vh - 49px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.card {
  width: 680px;
  max-width: 100%;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  border-radius: 10px;
  padding: 16px;
  border: 1px solid #e9e9ea;
  background: #ffffff;
  align-items: start;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.left {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e9e9ea;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #000000;
  flex-shrink: 0;
  letter-spacing: -0.5px;
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.03);
}

.brand-title {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 5px;
  flex: 1;
}

.brand-title .title {
  font-weight: 800;
  font-size: 18px;
}

.brand-title .sub {
  font-size: 13px;
  color: #666666;
}

.kbd {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.key {
  padding: 8px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e9e9ea;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.char {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  color: #000000;
}

.char.highlight {
  background: #000000;
  color: #ffffff;
}

aside {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px;
  align-self: start;
}

.field {
  font-size: 13px;
  color: #666666;
  font-weight: 700;
  display: block;
  margin-bottom: 6px;
}

.file-drop {
  padding: 10px;
  border-radius: 8px;
  border: 1px dashed #e9e9ea;
  cursor: pointer;
  background: #ffffff;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s;
}

.file-drop:hover,
.file-drop.dragover {
  border-color: #000000;
}

.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.file-drop-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #666666;
  pointer-events: none;
}

.file-name {
  font-size: 12px;
  color: #000000;
  margin-top: 5px;
  word-break: break-all;
  font-weight: 600;
  pointer-events: none;
}

input[type="text"] {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #e9e9ea;
  font-size: 13px;
  color: #000000;
  background: #ffffff;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color 0.15s;
}

input[type="text"]:focus {
  border-color: #000000;
}

input[type="text"]::placeholder {
  color: #666666;
}

.btn {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e9e9ea;
  background: #ffffff;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: #000000;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

.btn.primary {
  background: #000000;
  color: #ffffff;
  border: none;
  width: 100%;
  padding: 11px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:not(:disabled):hover {
  opacity: 0.8;
}

.progress-bar {
  height: 2px;
  background: #e9e9ea;
  border-radius: 2px;
  overflow: hidden;
  display: none;
}

.progress-bar.visible {
  display: block;
}

.progress-fill {
  height: 100%;
  background: #000000;
  animation: indeterminate 1.4s ease-in-out infinite;
}

@keyframes indeterminate {
  0%   { transform: translateX(-100%) scaleX(0.4); }
  100% { transform: translateX(250%)  scaleX(0.4); }
}

#status-msg {
  font-size: 12px;
  color: #e53935;
  min-height: 16px;
  text-align: center;
}

.dark-toggle {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #e9e9ea;
  background: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666666;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: auto;
  transition: border-color 0.15s, color 0.15s;
}

.dark-toggle:hover {
  border-color: #000000;
  color: #000000;
}

#game-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55) 0%, transparent 100%);
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 9999;
}

#game-topbar.active {
  display: flex;
}

.topbar-title {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-dot {
  width: 7px;
  height: 7px;
  background: #4caf50;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.close-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}

.close-btn:hover {
  background: rgba(229, 57, 53, 0.5);
  border-color: rgba(229, 57, 53, 0.6);
}

#controls-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 16px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.22) 75%, transparent 100%);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 9998;
  transition: opacity 0.4s;
}

#controls-overlay.active {
  display: flex;
}

#controls-overlay.hidden {
  opacity: 0;
}

.overlay-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: all;
  flex-wrap: wrap;
  justify-content: center;
}

.ov-btn {
  padding: 5px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: background 0.15s;
}

.ov-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.ov-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.vol-group {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  font-weight: 700;
}

input[type="range"]#volSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]#volSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

input[type="range"]#volSlider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.ov-sep {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
}

.overlay-keys {
  display: flex;
  align-items: center;
  gap: 6px 14px;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: none;
}

.ctrl-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
}

.ctrl-key {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  color: #ffffff;
  font-weight: 700;
}

.ctrl-sep {
  width: 1px;
  height: 12px;
  background: rgba(255, 255, 255, 0.15);
}

.cover-wrap {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.cover-wrap.visible {
  display: flex;
}

.cover-img {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e9e9ea;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
  display: block;
}

.cover-title {
  font-size: 13px;
  font-weight: 700;
  color: #000000;
  text-align: center;
  line-height: 1.3;
}

.cover-badge {
  font-size: 11px;
  color: #666666;
}

/* Dark mode :)))*/
body.dark {
  background: #0b0b0b;
  color: #e6eef8;
}

body.dark nav {
  background: #2a2a2a;
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

body.dark .nav-brand {
  color: #e6eef8;
  border-right-color: rgba(255, 255, 255, 0.06);
}

body.dark nav a {
  color: #9aa4b2;
}

body.dark nav a:hover {
  color: #e6eef8;
}

body.dark nav a.active {
  color: #e6eef8;
  border-bottom-color: #e6eef8;
}

body.dark .card {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.06);
}

body.dark .logo {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.06);
  color: #e6eef8;
}

body.dark .brand-title .title {
  color: #e6eef8;
}

body.dark .brand-title .sub {
  color: #9aa4b2;
}

body.dark .key {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.06);
  color: #e6eef8;
}

body.dark .char {
  color: #e6eef8;
}

body.dark .char.highlight {
  background: #e6eef8;
  color: #0b0b0b;
}

body.dark .field {
  color: #9aa4b2;
}

body.dark .file-drop {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.06);
}

body.dark .file-drop:hover,
body.dark .file-drop.dragover {
  border-color: #e6eef8;
}

body.dark .file-drop-inner {
  color: #9aa4b2;
}

body.dark .file-name {
  color: #e6eef8;
}

body.dark input[type="text"] {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.06);
  color: #e6eef8;
}

body.dark input[type="text"]:focus {
  border-color: #e6eef8;
}

body.dark input[type="text"]::placeholder {
  color: #9aa4b2;
}

body.dark .btn {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.06);
  color: #e6eef8;
}

body.dark .btn.primary {
  background: #e6eef8;
  color: #0b0b0b;
}

body.dark .progress-bar {
  background: rgba(255, 255, 255, 0.06);
}

body.dark .progress-fill {
  background: #e6eef8;
}

body.dark .dark-toggle {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.06);
  color: #9aa4b2;
}

body.dark .dark-toggle:hover {
  border-color: #e6eef8;
  color: #e6eef8;
}

body.dark .cover-img {
  border-color: rgba(255, 255, 255, 0.06);
}

body.dark .cover-title {
  color: #e6eef8;
}

body.dark .cover-badge {
  color: #9aa4b2;
}

/* this is to prevent a white splash, thank me later :) */
html.dark {
  background: #0b0b0b;
}